package systemRoutes

import (
	"baize/app/business/system/systemController"
	"baize/app/middlewares"
	"github.com/gin-gonic/gin"
)

func InitSysDictRouter(router *gin.RouterGroup, dict *systemController.Dict) {
	dictGroup := router.Group("/system/dict")
	dictGroup.GET("/data/list", middlewares.HasPermission("system:dict:list"), dict.DictDataList)
	dictGroup.GET("/data/export", middlewares.HasPermission("system:dict:export"), dict.DictDataExport)
	dictGroup.GET("/data/:dictCode", middlewares.HasPermission("system:dict:query"), dict.DictDataGetInfo)
	dictGroup.GET("/data/type/:dictType", dict.DictDataType)
	dictGroup.POST("/data", middlewares.SetLog(dictDataManagement, middlewares.Insert), middlewares.HasPermission("system:dict:add"), dict.DictDataAdd)
	dictGroup.PUT("/data", middlewares.SetLog(dictDataManagement, middlewares.Update), middlewares.HasPermission("system:dict:edit"), dict.DictDataEdit)
	dictGroup.DELETE("/data/:dictCodes", middlewares.SetLog(dictDataManagement, middlewares.Delete), middlewares.HasPermission("system:dict:remove"), dict.DictDataRemove)

	dictGroup.GET("/type/list", middlewares.HasPermission("system:dict:list"), dict.DictTypeList)
	dictGroup.POST("/type/export", middlewares.HasPermission("system:dict:export"), dict.DictTypeExport)
	dictGroup.GET("/type/:dictId", middlewares.HasPermission("system:dict:query"), dict.DictTypeGetInfo)
	dictGroup.POST("/type", middlewares.SetLog(dictTypeManagement, middlewares.Insert), middlewares.HasPermission("system:dict:add"), dict.DictTypeAdd)
	dictGroup.PUT("/type", middlewares.SetLog(dictTypeManagement, middlewares.Update), middlewares.HasPermission("system:dict:edit"), dict.DictTypeEdit)
	dictGroup.DELETE("/type/:dictIds", middlewares.SetLog(dictTypeManagement, middlewares.Delete), middlewares.HasPermission("system:dict:remove"), dict.DictTypeRemove)
	dictGroup.DELETE("/type/refreshCache", middlewares.SetLog(dictTypeManagement, middlewares.Clear), middlewares.HasPermission("system:dict:remove"), dict.DictTypeClearCache)
	dictGroup.GET("/type/optionSelect", dict.DictTypeOptionSelect)
}
